<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>

    </script>
</head>
<body>
<img src="../img/off.gif" alt="" id="img_con">
<script>
    let light = document.getElementById("img_con");
    let flag = true;
    light.onclick = function(){
        if (flag){
            light.src = "../img/on.gif";
            flag = false;
        }else{
            light.src = "../img/off.gif";
            flag = true;
        }
    }
</script>


</body>
</html>